<?php

namespace App\Services;

use Hashids\Hashids;
use TestingConfig;
class IdEncryptService {

    /**
     * @param string $id 加密或者解密的id
     * @param string $method 加密或者解密的关键字段
     * @return mixed 加密或者解密后的id
     */
    public static function encryption($id,$method){
        $content = TestingConfig::getValue('id_encode');
        $length = TestingConfig::getValue('id_encode_len');
        $hashids = new Hashids($content,(int)$length);
        return $hashids -> $method($id);
    }

}